<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>sock: E:/git/sock/sock/http/http_response.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">sock
   &#160;<span id="projectnumber">v0.11</span>
   </div>
   <div id="projectbrief">C++ Network Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_885cc87fac2d91e269af0a5a959fa5f6.html">E:</a></li><li class="navelem"><a class="el" href="dir_4e091ed8704426a7a4980368ba259fde.html">git</a></li><li class="navelem"><a class="el" href="dir_99ede9081e3122cb31ab1bd7b142cd6c.html">sock</a></li><li class="navelem"><a class="el" href="dir_7c33e989e8c050d7b2ba91a16c41033d.html">sock</a></li><li class="navelem"><a class="el" href="dir_2a6edac14fe64ddd5f5b32a053fdeecc.html">http</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">http_response.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="http__response_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Name         : http_response.h</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * Author       : 671643387</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Date         : 2015年10月10日</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * Description  :</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> *****************************************************************************/</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#ifndef SOCK_HTTP_HTTP_RESPONSE_H_</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#define SOCK_HTTP_HTTP_RESPONSE_H_</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &lt;boost/noncopyable.hpp&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;boost/shared_ptr.hpp&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="http__buffer_8h.html">sock/http/http_buffer.h</a>&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="tcp__connection__output__stream_8h.html">sock/net/tcp_connection_output_stream.h</a>&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="http__common_8h.html">sock/http/http_common.h</a>&gt;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacesock.html">sock</a></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;{</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    <span class="keyword">namespace </span>http</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    {</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;        <span class="keyword">class </span>HttpSession;</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="classsock_1_1http_1_1_http_response.html">   26</a></span>&#160;        <span class="keyword">class </span><a class="code" href="classsock_1_1http_1_1_http_response.html">HttpResponse</a> : <span class="keyword">public</span> boost::noncopyable</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;        {</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;            <a class="code" href="classsock_1_1http_1_1_http_response.html#a44adc96829b9a2afcdf7395e6fa2013c">HttpResponse</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;            <a class="code" href="classsock_1_1http_1_1_http_response.html#a9a03a4b1585dbff76f8712d686469b82">~HttpResponse</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="classsock_1_1http_1_1_http_response.html#ad591abcb16ff7b10ba680bbf0c00cac9">   36</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1http_1_1_http_response.html#ad591abcb16ff7b10ba680bbf0c00cac9">setStatusCode</a>(<span class="keywordtype">int</span> code) { code_ = code; }</div>
<div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="classsock_1_1http_1_1_http_response.html#a62b1124d617cbf0f88d6222c9d017ae2">   41</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1http_1_1_http_response.html#a62b1124d617cbf0f88d6222c9d017ae2">setMessage</a>(std::string message) { message_ = message; }</div>
<div class="line"><a name="l00046"></a><span class="lineno"><a class="line" href="classsock_1_1http_1_1_http_response.html#a13e8aeafa0925d27a59f33ca0e03fd5e">   46</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1http_1_1_http_response.html#a13e8aeafa0925d27a59f33ca0e03fd5e">setContentType</a>(std::string type) { contentType_ = type; }</div>
<div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="classsock_1_1http_1_1_http_response.html#abbb01a932e2c40a8f9d2928eaeff0d3a">   51</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classsock_1_1http_1_1_http_response.html#abbb01a932e2c40a8f9d2928eaeff0d3a">setCharset</a>(std::string charset) { charset_ = charset; }</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;</div>
<div class="line"><a name="l00057"></a><span class="lineno"><a class="line" href="classsock_1_1http_1_1_http_response.html#a00ea608d8e890ded25244cea39757d9a">   57</a></span>&#160;            <span class="keyword">const</span> <a class="code" href="namespacesock_1_1http.html#a4e8d5223a27396b63f6a4d96d9f2572b">HttpBufferPtr</a>&amp; <a class="code" href="classsock_1_1http_1_1_http_response.html#a00ea608d8e890ded25244cea39757d9a">getBuffer</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> buffer_; }</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="line" href="classsock_1_1http_1_1_http_response.html#a3e611175a551b64dda26f513067e0d04">   60</a></span>&#160;            <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classsock_1_1http_1_1_http_session.html">HttpSession</a>;</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;            <span class="keywordtype">void</span> setId(<span class="keywordtype">int</span> <span class="keywordtype">id</span>) { id_ = id; }</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;            <span class="keywordtype">int</span> getId(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> id_; }</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;            <span class="keywordtype">void</span> flushHead(<a class="code" href="classsock_1_1net_1_1_tcp_connection_output_stream.html">sock::net::TcpConnectionOutputStream</a>&amp; os);</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;            <span class="keywordtype">bool</span> isHeadFlushed(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> headFlushed_; }</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;            <a class="code" href="namespacesock_1_1http.html#ac5e7c0dc7506cb150c803b1e52020020">ConnectionState</a> getConnectionState(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> connState_; }</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;            <span class="keywordtype">void</span> setConnectionState(<a class="code" href="namespacesock_1_1http.html#ac5e7c0dc7506cb150c803b1e52020020">ConnectionState</a> state) { connState_ = state; }</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;            <span class="keywordtype">int</span> id_;</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;            <a class="code" href="namespacesock_1_1http.html#ac5e7c0dc7506cb150c803b1e52020020">ConnectionState</a> connState_;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;            <span class="keywordtype">bool</span> headFlushed_;              <span class="comment">/* 响应头是否输出 */</span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;            <span class="keywordtype">int</span> code_;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;            std::string message_;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;            <span class="keywordtype">size_t</span> contentLength_;</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;            std::string contentType_;</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;            std::string charset_;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;            <a class="code" href="namespacesock_1_1http.html#a4e8d5223a27396b63f6a4d96d9f2572b">HttpBufferPtr</a> buffer_;</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        };</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;</div>
<div class="line"><a name="l00087"></a><span class="lineno"><a class="line" href="namespacesock_1_1http.html#a1e8d565c94861f483cae82faa5d90ac8">   87</a></span>&#160;        <span class="keyword">typedef</span> boost::shared_ptr&lt;HttpResponse&gt; <a class="code" href="namespacesock_1_1http.html#a1e8d565c94861f483cae82faa5d90ac8">HttpResponsePtr</a>;</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;    }</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;}</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* SOCK_HTTP_HTTP_RESPONSE_H_ */</span><span class="preprocessor"></span></div>
<div class="ttc" id="namespacesock_1_1http_html_a4e8d5223a27396b63f6a4d96d9f2572b"><div class="ttname"><a href="namespacesock_1_1http.html#a4e8d5223a27396b63f6a4d96d9f2572b">sock::http::HttpBufferPtr</a></div><div class="ttdeci">boost::shared_ptr&lt; HttpBuffer &gt; HttpBufferPtr</div><div class="ttdef"><b>Definition:</b> http_buffer.h:154</div></div>
<div class="ttc" id="http__common_8h_html"><div class="ttname"><a href="http__common_8h.html">http_common.h</a></div></div>
<div class="ttc" id="classsock_1_1http_1_1_http_response_html_a9a03a4b1585dbff76f8712d686469b82"><div class="ttname"><a href="classsock_1_1http_1_1_http_response.html#a9a03a4b1585dbff76f8712d686469b82">sock::http::HttpResponse::~HttpResponse</a></div><div class="ttdeci">~HttpResponse(void)</div><div class="ttdef"><b>Definition:</b> http_response.cc:32</div></div>
<div class="ttc" id="classsock_1_1http_1_1_http_response_html_abbb01a932e2c40a8f9d2928eaeff0d3a"><div class="ttname"><a href="classsock_1_1http_1_1_http_response.html#abbb01a932e2c40a8f9d2928eaeff0d3a">sock::http::HttpResponse::setCharset</a></div><div class="ttdeci">void setCharset(std::string charset)</div><div class="ttdoc">设置字符集 </div><div class="ttdef"><b>Definition:</b> http_response.h:51</div></div>
<div class="ttc" id="tcp__connection__output__stream_8h_html"><div class="ttname"><a href="tcp__connection__output__stream_8h.html">tcp_connection_output_stream.h</a></div></div>
<div class="ttc" id="http__buffer_8h_html"><div class="ttname"><a href="http__buffer_8h.html">http_buffer.h</a></div></div>
<div class="ttc" id="classsock_1_1http_1_1_http_session_html"><div class="ttname"><a href="classsock_1_1http_1_1_http_session.html">sock::http::HttpSession</a></div><div class="ttdoc">HTTP Session. </div><div class="ttdef"><b>Definition:</b> http_session.h:28</div></div>
<div class="ttc" id="namespacesock_1_1http_html_ac5e7c0dc7506cb150c803b1e52020020"><div class="ttname"><a href="namespacesock_1_1http.html#ac5e7c0dc7506cb150c803b1e52020020">sock::http::ConnectionState</a></div><div class="ttdeci">ConnectionState</div><div class="ttdoc">连接状态 </div><div class="ttdef"><b>Definition:</b> http_common.h:35</div></div>
<div class="ttc" id="classsock_1_1http_1_1_http_response_html_ad591abcb16ff7b10ba680bbf0c00cac9"><div class="ttname"><a href="classsock_1_1http_1_1_http_response.html#ad591abcb16ff7b10ba680bbf0c00cac9">sock::http::HttpResponse::setStatusCode</a></div><div class="ttdeci">void setStatusCode(int code)</div><div class="ttdoc">设置响应码 </div><div class="ttdef"><b>Definition:</b> http_response.h:36</div></div>
<div class="ttc" id="namespacesock_html"><div class="ttname"><a href="namespacesock.html">sock</a></div><div class="ttdef"><b>Definition:</b> atomic.h:17</div></div>
<div class="ttc" id="classsock_1_1net_1_1_tcp_connection_output_stream_html"><div class="ttname"><a href="classsock_1_1net_1_1_tcp_connection_output_stream.html">sock::net::TcpConnectionOutputStream</a></div><div class="ttdoc">Tcp连接输出流 </div><div class="ttdef"><b>Definition:</b> tcp_connection_output_stream.h:20</div></div>
<div class="ttc" id="classsock_1_1http_1_1_http_response_html_a13e8aeafa0925d27a59f33ca0e03fd5e"><div class="ttname"><a href="classsock_1_1http_1_1_http_response.html#a13e8aeafa0925d27a59f33ca0e03fd5e">sock::http::HttpResponse::setContentType</a></div><div class="ttdeci">void setContentType(std::string type)</div><div class="ttdoc">设置内存类型 </div><div class="ttdef"><b>Definition:</b> http_response.h:46</div></div>
<div class="ttc" id="namespacesock_1_1http_html_a1e8d565c94861f483cae82faa5d90ac8"><div class="ttname"><a href="namespacesock_1_1http.html#a1e8d565c94861f483cae82faa5d90ac8">sock::http::HttpResponsePtr</a></div><div class="ttdeci">boost::shared_ptr&lt; HttpResponse &gt; HttpResponsePtr</div><div class="ttdef"><b>Definition:</b> http_response.h:87</div></div>
<div class="ttc" id="classsock_1_1http_1_1_http_response_html_a44adc96829b9a2afcdf7395e6fa2013c"><div class="ttname"><a href="classsock_1_1http_1_1_http_response.html#a44adc96829b9a2afcdf7395e6fa2013c">sock::http::HttpResponse::HttpResponse</a></div><div class="ttdeci">HttpResponse(void)</div><div class="ttdef"><b>Definition:</b> http_response.cc:15</div></div>
<div class="ttc" id="classsock_1_1http_1_1_http_response_html_a00ea608d8e890ded25244cea39757d9a"><div class="ttname"><a href="classsock_1_1http_1_1_http_response.html#a00ea608d8e890ded25244cea39757d9a">sock::http::HttpResponse::getBuffer</a></div><div class="ttdeci">const HttpBufferPtr &amp; getBuffer(void) const </div><div class="ttdoc">获取数据缓存 </div><div class="ttdef"><b>Definition:</b> http_response.h:57</div></div>
<div class="ttc" id="classsock_1_1http_1_1_http_response_html"><div class="ttname"><a href="classsock_1_1http_1_1_http_response.html">sock::http::HttpResponse</a></div><div class="ttdoc">HTTP响应 </div><div class="ttdef"><b>Definition:</b> http_response.h:26</div></div>
<div class="ttc" id="classsock_1_1http_1_1_http_response_html_a62b1124d617cbf0f88d6222c9d017ae2"><div class="ttname"><a href="classsock_1_1http_1_1_http_response.html#a62b1124d617cbf0f88d6222c9d017ae2">sock::http::HttpResponse::setMessage</a></div><div class="ttdeci">void setMessage(std::string message)</div><div class="ttdoc">设置响应消息 </div><div class="ttdef"><b>Definition:</b> http_response.h:41</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.10
</small></address>
</body>
</html>
